/*******************************************************************************
 * Copyright (c) 2008 Jakub Kornas.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Lesser Public License v2.1
 * which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
 * 
 * Contributors:
 *     Jakub Kornas - initial API and implementation
 *     Sylvain Sicard - integration in FracLite Runtime
 ******************************************************************************/

package org.objectweb.fractal.deployment.local.api;

import org.objectweb.fractal.api.Component;
import org.objectweb.fractal.api.Type;
import org.objectweb.fractal.api.factory.GenericFactory;
import org.objectweb.fractal.api.factory.InstantiationException;

/**
 * An extended {@link GenericFactory} to create {@link Component}s. It uses an
 * {@link IModuleComponentFactory} component to install packages given their
 * {@link IModuleDescriptor}s.
 * 
 * @author <a href="mailto:jakub.kornas@inrialpes.fr">Jakub Kornas
 * @uml.dependency supplier="org.objectweb.fractal.deployment.local.api.ComponentFactory"
 */
public interface IGenericFactoryWithModules extends GenericFactory {

	/**
	 * Creates a {@link Component} given its type, a description of its control
	 * part (membrane), description of its content part (implementation) and a
	 * module component that can load the resources building the desired
	 * component
	 * 
	 * @param type
	 *            The {@link Type} of the {@link Component} to be created
	 * @param controllerDesc
	 *            A description of the controller part of a component.
	 *            Implementation specific
	 * @param contentDesc
	 *            A description of the content part of a component.
	 *            Implementation specific
	 * @param module
	 *            an IModule interface of the module component to be used to
	 *            create the desired component
	 * 
	 */
	public Component newFcInstance(Type type, Object controllerDesc,
			Object contentDesc, IModule module) throws InstantiationException;

	/**
	 * Creates a {@link Component} given its type, a description of its control
	 * part (membrane), description of its content part (implementation) and a
	 * module component that can load the resources building the desired
	 * component
	 * 
	 * @param type
	 *            The {@link Type} of the {@link Component} to be created
	 * @param controllerDesc
	 *            A description of the controller part of a component.
	 *            Implementation specific
	 * @param contentDesc
	 *            A description of the content part of a component.
	 *            Implementation specific
	 * @param moduleComponent
	 *            a module component to be used to create the desired component
	 * 
	 */
	public Component newFcInstance(Type type, Object controllerDesc,
			Object contentDesc, Component moduleComponent)
			throws InstantiationException;

	/**
	 * Creates a {@link Component} given its type, a description of its control
	 * part (membrane), description of its content part (implementation) and an
	 * identifier of the module component that can load the resources building
	 * the desired component
	 * 
	 * @param type
	 *            The {@link Type} of the {@link Component} to be created
	 * @param controllerDesc
	 *            A description of the controller part of a component.
	 *            Implementation specific
	 * @param contentDesc
	 *            A description of the content part of a component.
	 *            Implementation specific
	 * @param moduleComponentDesc
	 *            an identifier of a module component to be used to create the
	 *            desired component
	 * 
	 */
	public Component newFcInstance(Type type, Object controllerDesc,
			Object contentDesc, Object moduleComponentDesc)
			throws InstantiationException;

	/**
	 * Undeploys a given {@link Component}
	 * 
	 * @param cmp
	 *            A {@link Component} to be undeployed
	 */
	public void undeployFcComponent(Component cmp);

	/**
	 * @return Returns the installer.
	 * @uml.property name="installer"
	 * @uml.associationEnd multiplicity="(1 1)"
	 *                     inverse="genericPackagedFactory:org.objectweb.fractal.deployment.local.api.Installer"
	 */
	// public Installer getInstaller();
	/**
	 * Setter of the property <tt>installer</tt>
	 * 
	 * @param installer
	 *            The installer to set.
	 * @uml.property name="installer"
	 */
	// public void setInstaller(Installer installer);
	/**
	 * Returns the {@link ILoader} associated with a given {@Component}
	 * 
	 * @param A
	 *            {@link Component} for which we want to obtain the
	 *            {@link ILoader}
	 * @return A {@link ILoader} for a given {@link Component}
	 */
	public ILoader getFcLoaderForComponent(Component cmp);

	public Component getSystemModule();

}
